package ArrDemo;

import java.util.Random;
import java.util.jar.JarEntry;

public class ArrDemo7 {
    public static void main(String[] args) {
        //建立数组
        int[] arr={1,2,3,4,5};
        //引入随机数
        Random r=new Random();
        for (int i = 0; i < arr.length; i++) {
            //随机交换数组中的元素
            int RandomIndex=r.nextInt(arr.length);
            int temp=arr[i];
            arr[i]=arr[RandomIndex];
            arr[RandomIndex]=temp;
        }

        //输出
        for (int i = 0; i < arr.length; i++) {
            System.out.print(arr[i]+" ");
        }
    }
}
